﻿<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.IO" %>
<%@ Page Title="Quizzes/Projects" Language="VB" AutoEventWireup="false" MasterPageFile="~/Site.Master" 
    CodeFile="Quizzes_Projects.aspx.vb" Inherits="Quiz_Projects" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        House's Quizzes
    </h2>
    <p>
        Please select a quiz to grade:
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem Value="Quiz1">Quiz 1</asp:ListItem>
            <asp:ListItem Value="Quiz2">Quiz 2</asp:ListItem>
        </asp:DropDownList>
&nbsp;<asp:Button ID="Button1" runat="server" Text="Load" OnClick="selectFile"/>
    </p>

    <script  runat="server">
        Sub selectFile(ByVal Source As Object, ByVal e As EventArgs)
            Dim sr1 As StreamReader = File.OpenText("C:\Users\magladek\workspace\chi-website-teachingassistant\House-" & DropDownList1.SelectedItem.ToString & ".txt")
            Dim sr2 As StreamReader = File.OpenText("C:\Users\magladek\workspace\chi-website-teachingassistant\" & DropDownList1.SelectedItem.ToString & "-key.txt")
            HouseQuiz1.Text = sr1.ReadToEnd.ToString
            Quiz1Key.Text = sr2.ReadToEnd.ToString
            sr1.Close()
            sr2.Close()
        End Sub
    </script>
    <script  runat="server">
        Sub calcGrade(ByVal Source As Object, ByVal e As EventArgs)
            Dim i1 As Integer = TextBox1.Text
            Dim i2 As Integer = TextBox2.Text
            Dim itot As Integer = i1 + i2
            Dim iString As String = itot
            TextBox6.Text = iString
        End Sub
    </script>
    <script  runat="server">
        Sub submitGrade(ByVal Source As Object, ByVal e As EventArgs)
            Dim sw As StreamWriter = File.AppendText("C:\Users\magladek\workspace\chi-website-teachingassistant\Grades.txt")
            sw.WriteLine("House-" & DropDownList1.SelectedItem.ToString & " Grade: " & TextBox6.Text.ToString)
            sw.WriteLine(" ")
            sw.Close()
        End Sub
    </script>
    <br />
    <strong>Quiz Submission&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Quiz Key</strong>
    <br /><br />
    <asp:TextBox ID="HouseQuiz1" runat="server" style="overflow:hidden" TextMode="multiline" Font-Names="Arial" Text=" " Wrap="true" Height="300" Width="425" ReadOnly="true" AutoPostBack="true"></asp:TextBox>
    &nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="Quiz1Key" runat="server" style="overflow:hidden" TextMode="multiline" Font-Names="Arial" Text=" " Wrap="true" Height="300" Width="425" ReadOnly="true" AutoPostBack="true"></asp:TextBox>
   
    <asp:rangevalidator id="RangeValidator1" runat="server" ErrorMessage="Write a correct number (0-1)" 
        ControlToValidate="TextBox2" Type="Integer" MaximumValue="1" MinimumValue="0"></asp:rangevalidator>
    <br />Question 1 (0-1): 
    <asp:TextBox ID="TextBox1" runat="server" style="text-align: right" 
        Width="22px" AutoPostBack="true"></asp:TextBox>
    <br />Question 2 (0-1): 
    <asp:TextBox ID="TextBox2" runat="server" style="text-align: right" 
        Width="22px" AutoPostBack="true"></asp:TextBox>
    
    <br />
    <asp:Button ID="Button2" runat="server" Text="Calculate Grade" OnClick="calcGrade" />
    <asp:TextBox ID="TextBox6" runat="server" Width="38px" AutoPostBack="true"></asp:TextBox>
    <br />
    <asp:Button ID="Button3" runat="server" Text="Submit Grade" OnClick="submitGrade" />

</asp:Content>
